package com.chhuang.ewcrm.application;

import com.chhuang.ewcrm.ctrl.LPKeyBoardController;
import javafx.application.Application;
import javafx.beans.property.StringProperty;
import javafx.fxml.FXMLLoader;
import javafx.fxml.JavaFXBuilderFactory;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Stage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.net.URL;

/**
 * @author chhuang
 * @create 2020-11-01-8:17
 */
public class LPKeyBoardApp extends Application {
    private final Logger logger = LoggerFactory.getLogger(LPKeyBoardApp.class);

    private StringProperty lptext;

    public LPKeyBoardApp(StringProperty lptext){
        this.lptext = lptext;
    }

    @Override
    public void start(Stage stage) {
        try {
            URL url = this.getClass().getResource("/fxml/lPKeyBoard.fxml");
            FXMLLoader fxmlLoader = new FXMLLoader();
            fxmlLoader.setLocation(url);
            fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory());
            Parent target = fxmlLoader.load(url.openStream());//载入窗口

            final LPKeyBoardController controller = fxmlLoader.getController();//获取controller
            controller.bindLPText(lptext);//绑定车牌字符串

            Scene scene = new Scene(target); //创建场景；
            stage.getIcons().add(new Image("/img/guangfuu.png"));
            scene.getStylesheets().add("org/kordamp/bootstrapfx/bootstrapfx.css");
            stage.setScene(scene); //将场景载入舞台；
            stage.setX(50);
            stage.setY(127);
            stage.show(); //显示窗口；
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
